
/*
 * Hlpay-Plus aggregate payment system.
 * Copyright (c) 2024-2025 Hlpay Team Copyright has the right of final interpretation.
 *
 */

package com.hlkj.pay.enums;

import lombok.Getter;

/**
 * @author HlpayTeam
 * @date 2024/09/27 17:45
 */
public interface AuthTokenEnum {

    @Getter
    enum AUTH_TOKEN_CLIENT_TYPE {

        PASSWORD(1, "PASSWORD"),
        CLIENT(2, "CLIENT"),
        MFG(4, "MFG"),

        ;

        /**
         * 错误码
         */
        private Integer code;

        /**
         * 错误提示
         */
        private String msg;

        AUTH_TOKEN_CLIENT_TYPE(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public static AUTH_TOKEN_CLIENT_TYPE from(Integer key) {
            AUTH_TOKEN_CLIENT_TYPE[] values = AUTH_TOKEN_CLIENT_TYPE.values();
            for (AUTH_TOKEN_CLIENT_TYPE deliveryType : values) {
                if (deliveryType.getCode().equals(key)) {
                    return deliveryType;
                }
            }
            return AUTH_TOKEN_CLIENT_TYPE.PASSWORD;
        }
    }
    @Getter
    enum AUTH_TOKEN_FIELD {
        
        TENANT_ID("tenantId", "tenantId"), USER_ID("userId", "userId"), APP_ID("appId", "appId"),SYS_TYPE("sysType", "sysType"),  SN("sn", "sn"),  AUTH_TOKEN_TYPE("authTokenType", "authTokenType");
        
        /**
         * 错误码
         */
        private String code;
        
        /**
         * 错误提示
         */
        private String msg;
        
        AUTH_TOKEN_FIELD(String code, String msg) {
            this.code = code;
            this.msg = msg;
        }
        
        public static AUTH_TOKEN_FIELD from(String key) {
            AUTH_TOKEN_FIELD[] values = AUTH_TOKEN_FIELD.values();
            for (AUTH_TOKEN_FIELD deliveryType : values) {
                if (deliveryType.getCode().equals(key)) {
                    return deliveryType;
                }
            }
            return AUTH_TOKEN_FIELD.TENANT_ID;
        }
    }
    
    @Getter
    enum AUTH_TOKEN_TYPE {
        
        ACCESS_TOKEN(1, "accessToken", "access"),
        REFRESH_TOKEN(2, "refreshToken", "refresh"),
        MFA_ACCESS_TOKEN(3, "mfaAccessToken", "mfa");
        
        /**
         * 错误码
         */
        private Integer code;
        
        /**
         * 错误提示
         */
        private String msg;
        
        /**
         * 错误提示
         */
        private String name;
        
        AUTH_TOKEN_TYPE(Integer code, String msg, String name) {
            this.code = code;
            this.msg = msg;
            this.name = name;
        }
        
        public static AUTH_TOKEN_TYPE from(Integer key) {
            AUTH_TOKEN_TYPE[] values = AUTH_TOKEN_TYPE.values();
            for (AUTH_TOKEN_TYPE deliveryType : values) {
                if (deliveryType.getCode().equals(key)) {
                    return deliveryType;
                }
            }
            return AUTH_TOKEN_TYPE.ACCESS_TOKEN;
        }
    }
    
    @Getter
    enum AUTH_MFA_TYPE {
        
        EMAIL(2, "email"), PHONE(1, "phone"),;
        
        /**
         * 错误码
         */
        private Integer code;
        
        /**
         * 错误提示
         */
        private String msg;
        
        AUTH_MFA_TYPE(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }
        
        public static AUTH_MFA_TYPE from(Integer key) {
            AUTH_MFA_TYPE[] values = AUTH_MFA_TYPE.values();
            for (AUTH_MFA_TYPE deliveryType : values) {
                if (deliveryType.getCode().equals(key)) {
                    return deliveryType;
                }
            }
            return AUTH_MFA_TYPE.EMAIL;
        }
    }
    
    @Getter
    enum AUTH_TOKEN_REQUEST_TYPE {
        
        PASSWORD(1, "PASSWORD"), PHONE(2, "phone"), CLIENT(4, "client"), MFA(8, "MFA"), MFA_TOKEN(16, "MFA_TOKEN"), REFRESH(32, "REFRESH"),
        
        ;
        
        /**
         * 错误码
         */
        private Integer code;
        
        /**
         * 错误提示
         */
        private String msg;
        
        AUTH_TOKEN_REQUEST_TYPE(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }
        
        public static AUTH_TOKEN_REQUEST_TYPE from(Integer key) {
            AUTH_TOKEN_REQUEST_TYPE[] values = AUTH_TOKEN_REQUEST_TYPE.values();
            for (AUTH_TOKEN_REQUEST_TYPE deliveryType : values) {
                if (deliveryType.getCode().equals(key)) {
                    return deliveryType;
                }
            }
            return AUTH_TOKEN_REQUEST_TYPE.PASSWORD;
        }
    }
    

    
}
